<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>入库单列表</title>
    <!--{include file='comm/comm_cal.tpl'}-->
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->

        <div class="comm_crub">
            <span class="now_crub">入库单列表</span>
        </div>

        <div class="comm_content">

            <div class="search-box">
                <div style="position:relative">
                    <form class="form-inline" id="search_form" onsubmit="return false;">
                        <table>
                            <tbody>
                            <tr>
                                <td>
                                    <span>入库单号：<input type="text" class="form-control input-sm" name="voucherCode" style="width: 130px;"></span>
                                    <span>创建人：<input type="text" class="form-control input-sm" name="creator" style="width: 130px;"></span>
                                    <span>
                                        创建时间：<input type="text" class="form-control input-sm" style="width: 100px;" id="startDate" name="startDate" readonly="readonly" />
                                        ～
                                        <input type="text"  class="form-control input-sm" style="width: 100px;" id="endDate" name="endDate" readonly="readonly" />
                                    </span>
                                    <span>
                                        <select class="form-control" name="voucherType">
                                            <option value="">请选择入库单类型</option>
                                            <option value="1">生产入库</option>
                                            <option value="2">退货入库</option>
                                            <option value="3">其他入库</option>
                                        </select>
                                    </span>
                                    <span>
                                        <button type="button" class="btn btn-primary btn-sm" onclick="putInStore.search();">查询</button>&nbsp;&nbsp;
                                        <button type="button" class="btn btn-primary btn-sm" onclick="putInStore.clear();">重置</button>&nbsp;&nbsp;
                                        <button type="button" class="btn btn-primary btn-sm" onclick="putInStore.import();">导入</button>
                                    </span>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>
            <div id="pop" style="display: none;">

                <form id="card_form" onsubmit="return false;">
                    <div class="input-group input-group-lg">
                        <span class="input-group-addon">好货数量：</span>
                        <input type="text" class="form-control" placeholder="请输入好货数量 【必填项】" name="good_amount" />
                    </div>
                    <div class="input-group input-group-lg">
                        <span class="input-group-addon">坏货数量：</span>
                        <input type="text" class="form-control" placeholder="请输入坏货数量 【必填项】" name="bad_amount" />
                    </div>
                    <div class="input-group input-group-lg">
                        <span class="input-group-addon">拒收数量：</span>
                        <input type="text" class="form-control" placeholder="请输入拒收数量 【必填项】" name="rejection_amount" />
                    </div>

                    <input type="hidden" name="uuid" value="" >
                    <input type="hidden" name="timeStamp" value="" >
                    <input type="hidden" name="operateFlag" value="" >

                </form>

            </div>

        </div>


</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/wms/putInStore.ajax?operFlg=3&xjx=none",
        dataType: "json",
        colModel : [
            <!--{if $EDIT_PERMISSION}-->
            {display: "操作", width : 150, align: "center"},
            <!--{/if}-->
            {display: "入库单号", align : 'center' ,name : "voucherID", width : 150, sortable : true},
            {display: "入库单类型", align : 'center' ,width : 150},
            {display: "商品总数",align : 'right',width : 100},
            {display: "总计金额", align : 'right',width : 120},
            {display: "创建时间",align : 'center' ,width : 200},
            {display: "创建人", width : 120},
            {display: "入库单状态", width : 120}
        ],
        <!--{if $EDIT_PERMISSION}-->
            buttons : [
                {name: "添加", bclass: "add", onpress : "putInStore.add"}
            ],
        <!--{/if}-->
        sortname: "voucherCode",
        sortorder: "DESC",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    var putInStore = {

        search: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();

        },

        add: function() {
            E.open("/quanliadmin/app/wms/warehouseManage.pscript?operFlg=2",'',{height: 600,width: 980, top: 50, left: 150});
        },

        clear : function (){
            $(".form-control").val("");
            this.search();
        },

        import : function (){
            E.open("/quanliadmin/app/wms/warehouseManage.pscript?operFlg=4",'',{height: 600,width: 980, top: 50, left: 150});
        },

        show: function( voucherID ) {
            E.open("/quanliadmin/app/wms/warehouseManage.pscript?operFlg=3&voucherID="+voucherID,'',{height: 600,width: 980  , top: 50, left: 150});
        },

        audit: {

            voucherID: "",
            flg		 : 0 ,
            open: function( voucherID , flg) {
                this.voucherID = voucherID;
                this.flg	   = flg;
                if(flg == 1)
                    E.open("/quanliadmin/app/wms/warehouseManage.pscript?operFlg=5&voucherID="+voucherID,'',{height: 600,width: 980  , top: 50, left: 150});
                else if(flg == 2)
                    putInStore.audit.cancelOpen();
            },

            cancelOpen:function(){

                var htmlString = '<table>';
                        htmlString += '<tr>';
                            htmlString += '<td style="width: 15%;text-align: right;">';
                                htmlString += '作废原因：';
                            htmlString += '</td>';
                            htmlString += '<td>';
                                htmlString += '<textarea name="cancelRemak" id="cancelRemak" style="width: 98%;height: 120px;"></textarea>';
                            htmlString += '</td>';
                        htmlString += '</tr>';
                    htmlString += '</table>';

                E.popup.open({
                    title: "作废入库单",
                    content: htmlString,
                    btnName: "提交",
                    btnCall: "putInStore.audit.cancelExe();"
                });

            },

            cancelExe:function(){

                var remark = $.trim( $("#cancelRemak").val() );

                if( remark == '' ){
                    E.alert('请填写作废原因');
                    return false;
                }

                E.loadding.open();
                E.ajax_get({
                    url: "/invokingAjax-backend/wms/putInStore.ajax?operFlg=5",
                    data:  {
                        voucherID: this.voucherID ,
                        flg		 : this.flg,
                        remark   : remark
                    },
                    call: "putInStore.audit.result"
                });

            },

            execute: function() {

                E.loadding.open();
                E.ajax_get({
                    url: "/invokingAjax-backend/wms/putInStore.ajax?operFlg=5",
                    data:  {
                        voucherID: this.voucherID ,
                        flg		 : this.flg
                    },
                    call: "putInStore.audit.result"
                });

            },

            result: function( o ) {

                E.loadding.close();
                E.popup.close();
                if (o.code == 200) {
                    E.alert(o.message, 2, "putInStore.load");
                } else {
                    E.alert(o.message);
                }

            }

        },

        load: function() {
            $("#flex").flexReload();
        }

    };

    //日期控件JS
    $('#startDate').datepicker();
    $('#endDate').datepicker();

</script>

</body>
</html>